package com.sinoglobal.dumping.dumplingdialog;

import android.view.View;

import com.sinoglobal.dumping.view.Dumpling_GetMoneyDialog;

/**
 * Created by KeZhuang on 2016/1/14.
 */
public class DumplingWishDialog extends DumplingDialogHelper implements DumplingIDialogFactory {

    @Override
    public Dumpling_GetMoneyDialog makeDialog(DumplingDialogHelper helper) {
        super.setValue(helper);
        Dumpling_GetMoneyDialog.Builder builder = getBuilder();
        builder
        .setType(Dumpling_GetMoneyDialog.TYPE_BLESSING)
        .setBtnLeftVISIBLE(getMoney() > 0.0 ? View.VISIBLE : View.GONE)
        .setBtnRightVISIBLE(View.VISIBLE)
        .setBtnLeftText(getMoney() > 0.0 ? (getLogin() ? "马上分享" : "去领取") : (getLogin() ? "马上分享" : "去领取"))
        .setBtnRightText("继续捞")
        .setCoreField(getDumplingVo().getPrizeInfo());
        if(getCount()==0){
            builder
                .setBtnLeftVISIBLE(getMoney() > 0.0 ? View.VISIBLE : View.GONE)
                .setBtnRightVISIBLE(getLogin() ? View.VISIBLE : (getMoney() <= 0.0 ? View.VISIBLE : View.GONE))
                .setBtnLeftText(getMoney() > 0.0 ? (getLogin() ? "马上分享" : "去领取") : "")
                .setBtnRightText(getLogin() ? (getMoney() > 0.0 ? "去钱包" : "明天再捞") : "登录继续")
                .setToast(getLogin() ? getShare() < 2 && getMoney() > 0.0 ? "马上分享,再得一次机会" : "机会用完啦" : "登录后，再得2次机会");
        }
        builder.setOnClick(new Dumpling_GetMoneyDialog.GetMoneyOnSureClick() {
                    @Override
                    public void onCloseClick() {
                    }

                    @Override
                    public void onBtnLeftClick() {
                        leftButtonClick();
                    }

                    @Override
                    public void onBtnRightClick() {
                        if (getCount() == 0) {
                            if (getLogin()) {
                                if (getMoney() == 0.0) {
                                    showToast("明天再捞");
                                } else {
                                    goWallet();
                                }
                            } else {
                               getDumpling(getContext());
                            }
                        } else if(getLogin()){
                            loginAcquireDumpling();
                        }else{
                            acquireDumpling();
                        }
                    }
                });
        return builder.builder();
    }
}
